<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <meta name="description" content="API docs for the addPoint method from the EffectLine class, for the Dart programming language.">
  <title>addPoint method - EffectLine class - spritewidget library - Dart API</title>
  <!-- required because all the links are pseudo-absolute -->
  <base href="../..">

  <link href="https://fonts.googleapis.com/css?family=Source+Code+Pro:500,400i,400,300|Source+Sans+Pro:400,300,700" rel="stylesheet">
  <link rel="stylesheet" href="static-assets/github.css">
  <link rel="stylesheet" href="static-assets/styles.css">
  <link rel="icon" href="static-assets/favicon.png">

</head>

<body>

<div id="overlay-under-drawer"></div>

<header id="title">
  <button id="sidenav-left-toggle" type="button">&nbsp;</button>
  <ol class="breadcrumbs gt-separated dark hidden-xs">
    <li><a href="index.html">spritewidget</a></li>
    <li><a href="spritewidget/spritewidget-library.html">spritewidget</a></li>
    <li><a href="spritewidget/EffectLine-class.html">EffectLine</a></li>
    <li class="self-crumb">addPoint method</li>
  </ol>
  <div class="self-name">addPoint</div>
  <form class="search navbar-right" role="search">
    <input type="text" id="search-box" autocomplete="off" disabled class="form-control typeahead" placeholder="Loading search...">
  </form>
</header>

<main>

  <div class="col-xs-6 col-sm-3 col-md-2 sidebar sidebar-offcanvas-left">
    <h5>EffectLine class</h5>
    <ol>
      <li class="section-title"><a href="spritewidget/EffectLine-class.html#constructors">Constructors</a></li>
      <li><a href="spritewidget/EffectLine/EffectLine.html">EffectLine</a></li>
    
      <li class="section-title">
        <a href="spritewidget/EffectLine-class.html#instance-properties">Properties</a>
      </li>
      <li><a href="spritewidget/EffectLine/animationMode.html">animationMode</a></li>
      <li><a href="spritewidget/EffectLine/colorSequence.html">colorSequence</a></li>
      <li><a href="spritewidget/EffectLine/fadeAfterDelay.html">fadeAfterDelay</a></li>
      <li><a href="spritewidget/EffectLine/fadeDuration.html">fadeDuration</a></li>
      <li><a href="spritewidget/EffectLine/maxWidth.html">maxWidth</a></li>
      <li><a href="spritewidget/EffectLine/minWidth.html">minWidth</a></li>
      <li><a href="spritewidget/EffectLine/points.html">points</a></li>
      <li><a href="spritewidget/EffectLine/scrollSpeed.html">scrollSpeed</a></li>
      <li><a href="spritewidget/EffectLine/simplify.html">simplify</a></li>
      <li><a href="spritewidget/EffectLine/texture.html">texture</a></li>
      <li><a href="spritewidget/EffectLine/textureLoopLength.html">textureLoopLength</a></li>
      <li><a href="spritewidget/EffectLine/transferMode.html">transferMode</a></li>
      <li><a href="spritewidget/EffectLine/widthGrowthSpeed.html">widthGrowthSpeed</a></li>
      <li><a href="spritewidget/EffectLine/widthMode.html">widthMode</a></li>
      <li class="inherited"><a href="spritewidget/Node/actions.html">actions</a></li>
      <li class="inherited"><a href="spritewidget/Node/children.html">children</a></li>
      <li class="inherited"><a href="spritewidget/Node/constraints.html">constraints</a></li>
      <li class="inherited"><a href="spritewidget/Node/handleMultiplePointers.html">handleMultiplePointers</a></li>
      <li class="inherited"><a href="dart-core/Object/hashCode.html">hashCode</a></li>
      <li class="inherited"><a href="spritewidget/Node/inverseTransformMatrix.html">inverseTransformMatrix</a></li>
      <li class="inherited"><a href="spritewidget/Node/parent.html">parent</a></li>
      <li class="inherited"><a href="spritewidget/Node/paused.html">paused</a></li>
      <li class="inherited"><a href="spritewidget/Node/position.html">position</a></li>
      <li class="inherited"><a href="spritewidget/Node/rotation.html">rotation</a></li>
      <li class="inherited"><a href="dart-core/Object/runtimeType.html">runtimeType</a></li>
      <li class="inherited"><a href="spritewidget/Node/scale.html">scale</a></li>
      <li class="inherited"><a href="spritewidget/Node/scaleX.html">scaleX</a></li>
      <li class="inherited"><a href="spritewidget/Node/scaleY.html">scaleY</a></li>
      <li class="inherited"><a href="spritewidget/Node/skewX.html">skewX</a></li>
      <li class="inherited"><a href="spritewidget/Node/skewY.html">skewY</a></li>
      <li class="inherited"><a href="spritewidget/Node/spriteBox.html">spriteBox</a></li>
      <li class="inherited"><a href="spritewidget/Node/transformMatrix.html">transformMatrix</a></li>
      <li class="inherited"><a href="spritewidget/Node/userInteractionEnabled.html">userInteractionEnabled</a></li>
      <li class="inherited"><a href="spritewidget/Node/visible.html">visible</a></li>
      <li class="inherited"><a href="spritewidget/Node/zPosition.html">zPosition</a></li>
    
      <li class="section-title"><a href="spritewidget/EffectLine-class.html#instance-methods">Methods</a></li>
      <li><a href="spritewidget/EffectLine/addPoint.html">addPoint</a></li>
      <li><a href="spritewidget/EffectLine/paint.html">paint</a></li>
      <li><a href="spritewidget/EffectLine/update.html">update</a></li>
      <li class="inherited"><a href="spritewidget/Node/addChild.html">addChild</a></li>
      <li class="inherited"><a href="spritewidget/Node/applyConstraints.html">applyConstraints</a></li>
      <li class="inherited"><a href="spritewidget/Node/computeTransformMatrix.html">computeTransformMatrix</a></li>
      <li class="inherited"><a href="spritewidget/Node/convertPointFromNode.html">convertPointFromNode</a></li>
      <li class="inherited"><a href="spritewidget/Node/convertPointToBoxSpace.html">convertPointToBoxSpace</a></li>
      <li class="inherited"><a href="spritewidget/Node/convertPointToNodeSpace.html">convertPointToNodeSpace</a></li>
      <li class="inherited"><a href="spritewidget/Node/handleEvent.html">handleEvent</a></li>
      <li class="inherited"><a href="spritewidget/Node/invalidateTransformMatrix.html">invalidateTransformMatrix</a></li>
      <li class="inherited"><a href="spritewidget/Node/isPointInside.html">isPointInside</a></li>
      <li class="inherited"><a href="dart-core/Object/noSuchMethod.html">noSuchMethod</a></li>
      <li class="inherited"><a href="spritewidget/Node/removeAllChildren.html">removeAllChildren</a></li>
      <li class="inherited"><a href="spritewidget/Node/removeChild.html">removeChild</a></li>
      <li class="inherited"><a href="spritewidget/Node/removeFromParent.html">removeFromParent</a></li>
      <li class="inherited"><a href="spritewidget/Node/spriteBoxPerformedLayout.html">spriteBoxPerformedLayout</a></li>
      <li class="inherited"><a href="dart-core/Object/toString.html">toString</a></li>
    
      <li class="section-title inherited"><a href="spritewidget/EffectLine-class.html#operators">Operators</a></li>
      <li class="inherited"><a href="dart-core/Object/operator_equals.html">operator ==</a></li>
    
    
    
    </ol>
  </div><!--/.sidebar-offcanvas-->

  <div class="col-xs-12 col-sm-9 col-md-8 main-content">
    <h1>addPoint method</h1>

    <section class="multi-line-signature">
      <span class="returntype">void</span>
      <span class="name ">addPoint</span>
(<wbr><span class="parameter" id="addPoint-param-point"><span class="type-annotation"><a href="dart-ui/Offset-class.html">Offset</a></span> <span class="parameter-name">point</span></span>)
    </section>
    <section class="desc markdown">
      <p>Adds a new point to the end of the line.</p>
    </section>
    
    <section class="summary source-code" id="source">
      <h2><span>Implementation</span> </h2>
      <pre class="language-dart"><code class="language-dart">void addPoint(Offset point) {
  &#47;&#47; Skip duplicate points
  if (points.length &gt; 0 &amp;&amp; point.dx == points[points.length - 1].dx &amp;&amp; point.dy == points[points.length - 1].dy)
    return;

  if (simplify &amp;&amp; points.length &gt;= 2 &amp;&amp; GameMath.distanceBetweenPoints(point, points[points.length - 2]) &lt; 10.0) {
    &#47;&#47; Check if we should remove last point before adding the new one

    &#47;&#47; Calculate the square distance from the middle point to the line of the
    &#47;&#47; new point and the second to last point
    double dist2 = _distToSeqment2(
      points[points.length - 1],
      point,
      points[points.length - 2]
    );

    &#47;&#47; If the point is on the line, remove it
    if (dist2 &lt; 1.0) {
      _points.removeAt(_points.length - 1);
    }
  }

  &#47;&#47; Add point and point&#39;s age
  _points.add(point);
  _pointAges.add(0.0);
}</code></pre>
    </section>

  </div> <!-- /.main-content -->

  <div class="col-xs-6 col-sm-6 col-md-2 sidebar sidebar-offcanvas-right">
  </div><!--/.sidebar-offcanvas-->

</main>

<footer>
  <span class="no-break">
    spritewidget 0.9.16
  </span>

</footer>

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="static-assets/typeahead.bundle.min.js"></script>
<script src="static-assets/highlight.pack.js"></script>
<script src="static-assets/URI.js"></script>
<script src="static-assets/script.js"></script>


</body>

</html>
